package mapEditor.view.panels
{
	import asset.mapEditor.panelListAsset;
	
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	import mapEditor.model.EditorModel;
	import mapEditor.vo.PanelType;
	
	public class PanelListView extends panelListAsset
	{
		private var _model:EditorModel;
		
		public function PanelListView(model:EditorModel)
		{
			_model=model;
			setView();
			setEvent();
		}
		
		private function setView():void
		{
			resetPanelBtn();
		}
		
		private function setEvent():void
		{
			addEventListener(Event.ADDED_TO_STAGE, __onAddedToStage);
			panelAttrib.addEventListener(MouseEvent.CLICK, __onClick);
			panelLib.addEventListener(MouseEvent.CLICK, __onClick);
		}
		
		private function __onAddedToStage(evt:Event):void
		{
			stage.addEventListener(Event.RESIZE, __onResize);
			listBg.height=stage.stageHeight-y;
		}
		
		private function __onResize(evt:Event):void
		{
			listBg.height=stage.stageHeight-y;
			x=stage.stageWidth-width;
		}	
		
		private function __onClick(evt:MouseEvent):void
		{
			switch(evt.currentTarget)
			{
				case panelAttrib://属性面板
					_model.panelType=PanelType.PANEL_ATTRIB;
					break;
				case panelLib://库面板
					_model.panelType=PanelType.PANEL_LIB;
					break;
			}
		}
		
		private function resetPanelBtn():void
		{
			panelAttrib.gotoAndStop(1);
			panelLib.gotoAndStop(1);
		}
		
		public function dispose():void
		{
			if(parent) parent.removeChild(this);
		}
	}
}